<template>
    <el-card>
        <!--搜索组件-->
        <company-register-search :companySearch="searchBean" />
        <!-- 分隔符 -->
        <hr />
        <!--数据展示-->
        <company-register-data :formDefinition="dataFormBean" :data="tableData.result" @auditCompany="auditCompany" />
        <!--分页组件-->
        <page :total="tableData.total" />
        <!-- 对话框组件 -->
        <el-dialog width="680px" :visible.sync="dialogSwitch" :before-close="beforeClose" :close-on-click-modal="false"
            :destroy-on-close="true">

            <company-register-audit :data="auditData"/>

            <!-- 对话框组件的按钮-->
            <template #footer>
                <el-button @click="confirmExecute" type="primary" size="mini">审核通过</el-button>
                <el-button @click="confirmExecute" type="warning" size="mini">审核驳回</el-button>
                <el-button @click="switchEvent" type="info" size="mini">取消</el-button>
            </template>
        </el-dialog>
    </el-card>
</template>

<script>
import companyRegisterSearch from './companyRegisterSearch.vue';
import companyRegisterData from './companyRegisterData.vue';
import companyRegisterAudit from './companyRegisterAudit.vue';
import page from "@/components/common/page.vue";
import { searchBean, dataFormBean } from './entity/companyRegisterEntity';
import { getRegisterList } from '@/api/common/auditProcessApi'


export default {
    components: { companyRegisterSearch, companyRegisterData, page, companyRegisterAudit },
    data() {
        return {
            searchBean,
            dataFormBean,
            tableData: {},
            dialogSwitch: false,
            auditData:{}
        }
    },
    methods: {
        loadCompanyPageData() {
            getRegisterList(this.searchBean).then(data => {
                data.result.map(d => d.newAddress = d.province + d.city + d.district + d.address);
                this.tableData = data;
            }).catch(err => {
                this.$message.error(err);
            })
        },
        //点击审核按钮
        auditCompany(row) {
            this.auditData = row;
            this.auditData.pcdCode = [row.provinceCode,row.cityCode,row.districtCode];
            console.log(this.auditData)
            this.switchEvent();
        },
        //对话框执行
        confirmExecute() {

        },
        //对话框关闭前校验
        beforeClose(done) {
            if (this.visible) {
                done();
            } else {
                done(false);
            }
        },
        //对话框开关
        switchEvent() {
            this.dialogSwitch = !this.dialogSwitch;
        },
    },
    mounted() {
        this.loadCompanyPageData();
    }
}
</script>

<style scoped lang="scss"></style>
